﻿using Tools.Domain.Common.Repositories.Contracts;
using Webshop20.Domain.Security.Authentication.Core;

namespace Webshop20.Application.Queries.Services
{

    public interface IGetAccountByIdService : IService{}

    public class GetAccountByIdService : ServiceBase, IGetAccountByIdService
    {

        private readonly IRepository<Account> accountRepository;


        public GetAccountByIdService(IRepository<Account> accountRepository)
        {
            this.accountRepository = accountRepository;
        }

        public override ISystemMessage Handle(ISystemMessage request)
        {
            var accountByIdReq = request as GetAccountByIdRequest;
            return new GetAccountByIdResponse(accountRepository.FindById(accountByIdReq.Id));
        }   
    }
}
